/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "zobjects_gtk.h"

#define PREFIX_ROW_DATA_KEY	"row-data-"

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_Create_guiwindow;
int ZlangInvokeFunction_guicombobox_Create_guiwindow( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(out1) ;
	struct ZlangDirectProperty_guiwidget_common	*guicombobox_common = & (guicombobox_direct_prop->common) ;
	GtkListStore					*gtk_list_store = NULL ;
	GtkCellRenderer					*renderer = NULL ;

	EVAL_GTK_WIDGET_NEW_IN_CREATE( gtk_list_store , gtk_list_store_new( 1 , G_TYPE_STRING ) )
	EVAL_GTK_WIDGET_NEW_IN_CREATE( guicombobox_common->gtk_widget , gtk_combo_box_new_with_model( GTK_TREE_MODEL(gtk_list_store) ) )
	SET_CONTROL_DEFAULT_STYLE( in1 , guicombobox_common->gtk_widget )
	EVAL_GTK_WIDGET_NEW_IN_CREATE( renderer , gtk_cell_renderer_text_new() )
	gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(guicombobox_common->gtk_widget) , renderer , TRUE );
	gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(guicombobox_common->gtk_widget) , renderer , "text" , 0 , NULL );

	TRANSFER_INPUT_OBJECT_TO_NEW_OBJECT( guicombobox_common->guiwindow_obj , in1 )

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_Create_guiwindow_functionptr;
int ZlangInvokeFunction_guicombobox_Create_guiwindow_functionptr( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(out1) ;
	struct ZlangDirectProperty_guiwidget_common	*guicombobox_common = & (guicombobox_direct_prop->common) ;
	GtkListStore					*gtk_list_store = NULL ;
	GtkCellRenderer					*renderer = NULL ;

	EVAL_GTK_WIDGET_NEW_IN_CREATE( gtk_list_store , gtk_list_store_new( 1 , G_TYPE_STRING ) )
	EVAL_GTK_WIDGET_NEW_IN_CREATE( guicombobox_direct_prop->common.gtk_widget , gtk_combo_box_new_with_model( GTK_TREE_MODEL(gtk_list_store) ) )
	SET_CONTROL_DEFAULT_STYLE( in1 , guicombobox_common->gtk_widget )
	EVAL_GTK_WIDGET_NEW_IN_CREATE( renderer , gtk_cell_renderer_text_new() )
	gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(guicombobox_direct_prop->common.gtk_widget) , renderer , TRUE );
	gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(guicombobox_direct_prop->common.gtk_widget) , renderer , "text" , 0 , NULL );

	TRANSFER_INPUT_OBJECT_TO_NEW_OBJECT( guicombobox_common->guiwindow_obj , in1 )

	ADD_CONTROL_GENERAL_CALLBACK_IN_CREATE( guicombobox_common->guiwindow_obj , out1 , GTK_EVENT_CHANGED , in2 )

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_AppendStringItem_string;
int ZlangInvokeFunction_guicombobox_AppendStringItem_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*gtk_list_store = NULL ;
	char						*str = NULL ;
	GtkTreeIter					iter ;

	CallRuntimeFunction_string_GetStringValue( rt , in1 , & str , NULL );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	gtk_list_store = GTK_LIST_STORE(model) ;

	gtk_list_store_append( gtk_list_store , & iter );
	gtk_list_store_set( gtk_list_store , & iter , 0 , str , -1 );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_AppendStringItems_vargs;
int ZlangInvokeFunction_guicombobox_AppendStringItems_vargs( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	int						count ;
	int						no ;
	struct ZlangObject				*inN = NULL ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*gtk_list_store = NULL ;
	char						*str = NULL ;
	GtkTreeIter					iter ;

	count = GetInputParameterCountInLocalObjectStack( rt ) ;
	for( no = 1 ; no <= count ; no++ )
	{
		inN = GetInputParameterInLocalObjectStack( rt , no ) ;
		if( inN == NULL )
		{
			return ThrowErrorException( rt , EXCEPTION_CODE_GENERAL , EXCEPTION_MESSAGE_INTERNAL_ERROR );
		}

		if( ! IsTypeOf( rt , inN , GetStringObjectInRuntimeObjectsHeap(rt) ) )
		{
			return ThrowErrorException( rt , EXCEPTION_CODE_GENERAL , EXCEPTION_MESSAGE_OBJECT_TYPE_INVALID );
		}

		CallRuntimeFunction_string_GetStringValue( rt , inN , & str , NULL );

		model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
		gtk_list_store = GTK_LIST_STORE(model) ;

		gtk_list_store_append( gtk_list_store , & iter );
		gtk_list_store_set( gtk_list_store , & iter , 0 , str , -1 );
	}

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_InsertStringItem_int_string;
int ZlangInvokeFunction_guicombobox_InsertStringItem_int_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*list_store = NULL ;
	char						*str = NULL ;
	GtkTreeIter					iter ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );
	CallRuntimeFunction_string_GetStringValue( rt , in2 , & str , NULL );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;

	gtk_list_store_insert( list_store , & iter , row_no-1 );
	gtk_list_store_set( list_store , & iter , 0 , str , -1 );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_SetStringItem_int_string;
int ZlangInvokeFunction_guicombobox_SetStringItem_int_string( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*list_store = NULL ;
	char						*str = NULL ;
	GtkTreeIter					iter ;
	unsigned char					b ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );
	CallRuntimeFunction_string_GetStringValue( rt , in2 , & str , NULL );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;

	b = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(list_store) , & iter , NULL , row_no-1 ) ;
	if( b != TRUE )
	{
		UnreferObject( rt , out1 );
		return 0;
	}
	gtk_list_store_set( list_store , & iter , 0 , str , -1 );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_AppendItem_object_object;
int ZlangInvokeFunction_guicombobox_AppendItem_object_object( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*new_combobox_row_obj = NULL ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*list_store = NULL ;
	GtkTreeIter					iter ;
	GtkTreePath					*combobox_row_path = NULL ;
	struct ZlangObject				*tostr_obj = NULL ;
	char						*str = NULL ;
	char						*combobox_row_path_str = NULL ;
	char						row_data_key[ 64 ] ;
	int						nret = 0 ;

	in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	if( in2 == NULL || IsObjectPropertiesEntityNull(in2) )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID )
		return ThrowErrorException( rt , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID );
	}
	nret = CloneObject( rt , & new_combobox_row_obj , NULL , in2 ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED );
	}

	in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	nret = ToString( rt , in1 , & tostr_obj ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_TO_STRING )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_TO_STRING );
	}
	CallRuntimeFunction_string_GetStringValue( rt , tostr_obj , & str , NULL );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;

	gtk_list_store_append( list_store , & iter );
	gtk_list_store_set( list_store , & iter , 0 , str , -1 );
	combobox_row_path = gtk_tree_model_get_path( GTK_TREE_MODEL(list_store) , & iter ) ;
	combobox_row_path_str = gtk_tree_path_to_string( combobox_row_path ) ;
	memset( row_data_key , 0x00 , sizeof(row_data_key) );
	snprintf( row_data_key , sizeof(row_data_key)-1 , PREFIX_ROW_DATA_KEY"%s" , combobox_row_path_str );
	g_free( combobox_row_path_str );
	g_object_set_data_full( G_OBJECT(list_store) , row_data_key , new_combobox_row_obj , FastDestroyObject );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_InsertItem_int_object_object;
int ZlangInvokeFunction_guicombobox_InsertItem_int_object_object( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	struct ZlangObject				*new_combobox_row_obj = NULL ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*list_store = NULL ;
	GtkTreeIter					iter ;
	GtkTreePath					*combobox_row_path = NULL ;
	struct ZlangObject				*tostr_obj = NULL ;
	char						*str = NULL ;
	char						*combobox_row_path_str = NULL ;
	char						row_data_key[ 64 ] ;
	int						nret = 0 ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );

	in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	if( in3 == NULL || IsObjectPropertiesEntityNull(in3) )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID )
		return ThrowErrorException( rt , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID );
	}
	nret = CloneObject( rt , & new_combobox_row_obj , NULL , in3 ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED );
	}

	in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	nret = ToString( rt , in2 , & tostr_obj ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_TO_STRING )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_TO_STRING );
	}
	CallRuntimeFunction_string_GetStringValue( rt , tostr_obj , & str , NULL );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;

	gtk_list_store_insert( list_store , & iter , row_no-1 );
	gtk_list_store_set( list_store , & iter , 0 , str , -1 );
	combobox_row_path = gtk_tree_model_get_path( GTK_TREE_MODEL(list_store) , & iter ) ;
	combobox_row_path_str = gtk_tree_path_to_string( combobox_row_path ) ;
	memset( row_data_key , 0x00 , sizeof(row_data_key) );
	snprintf( row_data_key , sizeof(row_data_key)-1 , PREFIX_ROW_DATA_KEY"%s" , combobox_row_path_str );
	g_free( combobox_row_path_str );
	g_object_set_data_full( G_OBJECT(list_store) , row_data_key , new_combobox_row_obj , FastDestroyObject );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_SetItem_int_object_object;
int ZlangInvokeFunction_guicombobox_SetItem_int_object_object( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	struct ZlangObject				*in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						row_no ;
	struct ZlangObject				*new_combobox_row_obj = NULL ;
	GtkTreeModel					*model = NULL ;
	GtkListStore					*list_store = NULL ;
	GtkTreeIter					iter ;
	GtkTreePath					*combobox_row_path = NULL ;
	struct ZlangObject				*tostr_obj = NULL ;
	char						*str = NULL ;
	char						*combobox_row_path_str = NULL ;
	char						row_data_key[ 64 ] ;
	unsigned char					b ;
	int						nret = 0 ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );

	in3 = GetInputParameterInLocalObjectStack(rt,3) ;
	if( in3 == NULL || IsObjectPropertiesEntityNull(in3) )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID )
		return ThrowErrorException( rt , ZLANG_ERROR_INVOKE_METHOD_RETURN , EXCEPTION_MESSAGE_PARAMETERS_INVALID );
	}
	nret = CloneObject( rt , & new_combobox_row_obj , NULL , in3 ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_ALLOC_CONTROL_CALLBACK_EVENT_FAILED );
	}

	in2 = GetInputParameterInLocalObjectStack(rt,2) ;
	nret = ToString( rt , in2 , & tostr_obj ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , nret , EXCEPTION_MESSAGE_TO_STRING )
		return ThrowErrorException( rt , nret , EXCEPTION_MESSAGE_TO_STRING );
	}
	CallRuntimeFunction_string_GetStringValue( rt , tostr_obj , & str , NULL );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;

	b = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(list_store) , & iter , NULL , row_no-1 ) ;
	if( b != TRUE )
	{
		UnreferObject( rt , out1 );
		return 0;
	}
	gtk_list_store_set( list_store , & iter , 0 , str , -1 );
	combobox_row_path = gtk_tree_model_get_path( GTK_TREE_MODEL(list_store) , & iter ) ;
	combobox_row_path_str = gtk_tree_path_to_string( combobox_row_path ) ;
	memset( row_data_key , 0x00 , sizeof(row_data_key) );
	snprintf( row_data_key , sizeof(row_data_key)-1 , PREFIX_ROW_DATA_KEY"%s" , combobox_row_path_str );
	g_free( combobox_row_path_str );
	g_object_set_data_full( G_OBJECT(list_store) , row_data_key , new_combobox_row_obj , FastDestroyObject );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_SetChangedEventCallback_functionptr;
int ZlangInvokeFunction_guicombobox_SetChangedEventCallback_functionptr( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangDirectProperty_guiwidget_common	*guicombobox_common = & (guicombobox_direct_prop->common) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;

	ADD_CONTROL_GENERAL_CALLBACK_IN_CREATE( guicombobox_common->guiwindow_obj , obj , GTK_EVENT_CHANGED , in1 )

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_SelectRow_int;
int ZlangInvokeFunction_guicombobox_SelectRow_int( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject				*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject				*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t						index ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & index );

	gtk_combo_box_set_active( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) , index-1 );

	TRANSFER_MASTER_OBJECT_TO_OUTPUT_OBJECT

	return 0;
}

ZLANG_INVOKE_FUNCTION_guiwidget_all_common_functions( combobox )

ZLANG_INVOKE_FUNCTION_guictl_all_common_functions( combobox )

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_Remove_int;
int ZlangInvokeFunction_guicombobox_Remove_int( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*in1 = GetInputParameterInLocalObjectStack(rt,1) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t					row_no ;
	GtkTreeModel				*model = NULL ;
	GtkListStore				*list_store = NULL ;
	int32_t					item_count ;
	GtkTreeIter				iter ;
	unsigned char				b ;

	CallRuntimeFunction_int_GetIntValue( rt , in1 , & row_no );

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;
	item_count = gtk_tree_model_iter_n_children( model , NULL ) ;

	b = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(list_store) , & iter , NULL , row_no-1 ) ;
	if( b != TRUE )
	{
		CallRuntimeFunction_bool_SetBoolValue( rt , out1 , FALSE );
		return 0;
	}
	gtk_list_store_remove( list_store , & iter );
	if( row_no > item_count )
		gtk_combo_box_set_active( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) , item_count-1 );
	else
		gtk_combo_box_set_active( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) , row_no-1 );

	CallRuntimeFunction_bool_SetBoolValue( rt , out1 , TRUE );
	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_RemoveAll;
int ZlangInvokeFunction_guicombobox_RemoveAll( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	GtkTreeModel				*model = NULL ;
	GtkListStore				*list_store = NULL ;

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	list_store = GTK_LIST_STORE(model) ;

	gtk_list_store_clear( list_store );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_GetItemCount;
int ZlangInvokeFunction_guicombobox_GetItemCount( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkTreeModel				*model = NULL ;
	int32_t					item_count ;

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	item_count = gtk_tree_model_iter_n_children( model , NULL ) ;
	CallRuntimeFunction_int_SetIntValue( rt , out1 , item_count );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_GetSelectedRowNo;
int ZlangInvokeFunction_guicombobox_GetSelectedRowNo( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	int32_t					index ;

	index = gtk_combo_box_get_active( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	CallRuntimeFunction_int_SetIntValue( rt , out1 , index+1 );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_GetSelectedRowString;
int ZlangInvokeFunction_guicombobox_GetSelectedRowString( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkTreeModel				*model = NULL ;
	GtkTreeIter				iter ;
	char					*str = NULL ;

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	if( ! gtk_combo_box_get_active_iter( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) , & iter ) )
	{
		UnreferObject( rt , out1 );
		return 0;
	}

	gtk_tree_model_get( model , & iter , 0 , & str , -1 );
	CallRuntimeFunction_string_SetStringValue( rt , out1 , str , STRLEN_OF_STRING );

	return 0;
}

ZlangInvokeFunction ZlangInvokeFunction_guicombobox_GetSelectedRowObject;
int ZlangInvokeFunction_guicombobox_GetSelectedRowObject( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	struct ZlangObject			*out1 = GetOutputParameterInLocalObjectStack(rt,1) ;
	GtkTreeModel				*model = NULL ;
	GtkListStore				*gtk_list_store = NULL ;
	GtkTreeIter				iter ;
	GtkTreePath				*combobox_row_path = NULL ;
	char					*combobox_row_path_str = NULL ;
	char					row_data_key[ 64 ] ;
	struct ZlangObject			*combobox_row_obj = NULL ;
	int					nret = 0 ;

	model = gtk_combo_box_get_model( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) ) ;
	if( ! gtk_combo_box_get_active_iter( GTK_COMBO_BOX(guicombobox_direct_prop->common.gtk_widget) , & iter ) )
	{
		UnreferObject( rt , out1 );
		return 0;
	}
	gtk_list_store = GTK_LIST_STORE(model) ;

	combobox_row_path = gtk_tree_model_get_path( model , & iter ) ;
	combobox_row_path_str = gtk_tree_path_to_string( combobox_row_path ) ;
	memset( row_data_key , 0x00 , sizeof(row_data_key) );
	snprintf( row_data_key , sizeof(row_data_key)-1 , PREFIX_ROW_DATA_KEY"%s" , combobox_row_path_str );
	g_free( combobox_row_path_str );
	combobox_row_obj = g_object_get_data( G_OBJECT(gtk_list_store) , row_data_key ) ;
	nret = ReferObject( rt , out1 , combobox_row_obj ) ;
	if( nret )
	{
		UnreferObject( rt , out1 );
		return 0;
	}

	return 0;
}

ZlangCreateDirectPropertyFunction ZlangCreateDirectProperty_guicombobox;
void *ZlangCreateDirectProperty_guicombobox( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox		*guicombobox_prop = NULL ;
	struct ZlangDirectProperty_guiwidget_common	*guicombobox_common = NULL ;

	
	guicombobox_prop = (struct ZlangDirectProperty_guicombobox *)ZLMALLOC( sizeof(struct ZlangDirectProperty_guicombobox) ) ;
	if( guicombobox_prop == NULL )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_ALLOC , "alloc memory for entity" )
		return NULL;
	}
	memset( guicombobox_prop , 0x00 , sizeof(struct ZlangDirectProperty_guicombobox) );

	guicombobox_common = (struct ZlangDirectProperty_guiwidget_common *)guicombobox_prop ;
	guicombobox_common->gtk_widget_type_id = GTK_TYPE_COMBO_BOX ;

	INIT_ZLANGDIRECTPROPERTY_guiwidget_common(guicombobox)
	
	return guicombobox_prop;
}

ZlangDestroyDirectPropertyFunction ZlangDestroyDirectProperty_guicombobox;
void ZlangDestroyDirectProperty_guicombobox( struct ZlangRuntime *rt , struct ZlangObject *obj )
{
	struct ZlangDirectProperty_guicombobox	*guicombobox_direct_prop = GetObjectDirectProperty(obj) ;
	
	CLEAN_ZLANGDIRECTPROPERTY_guiwidget_common(guicombobox)

	ZLFREE( guicombobox_direct_prop );
	
	return;
}

ZlangSummarizeDirectPropertySizeFunction ZlangSummarizeDirectPropertySize_guicombobox;
void ZlangSummarizeDirectPropertySize_guicombobox( struct ZlangRuntime *rt , struct ZlangObject *obj , size_t *summarized_obj_size , size_t *summarized_direct_prop_size )
{
	SUMMARIZE_SIZE( summarized_direct_prop_size , sizeof(struct ZlangDirectProperty_guicombobox) )
	return;
}

static struct ZlangDirectFunctions direct_funcs_guicombobox =
	{
		ZLANG_OBJECT_guicombobox , /* char *ancestor_name */
		
		ZlangCreateDirectProperty_guicombobox , /* ZlangCreateDirectPropertyFunction *create_entity_func */
		ZlangDestroyDirectProperty_guicombobox , /* ZlangDestroyDirectPropertyFunction *destroy_entity_func */
		
		NULL , /* ZlangFromCharPtrFunction *from_char_ptr_func */
		NULL , /* ZlangToStringFunction *to_string_func */
		NULL , /* ZlangFromDataPtrFunction *from_data_ptr_func */
		NULL , /* ZlangGetDataPtrFunction *get_data_ptr_func */
		
		NULL , /* ZlangOperatorFunction *oper_PLUS_func */
		NULL , /* ZlangOperatorFunction *oper_MINUS_func */
		NULL , /* ZlangOperatorFunction *oper_MUL_func */
		NULL , /* ZlangOperatorFunction *oper_DIV_func */
		NULL , /* ZlangOperatorFunction *oper_MOD_func */
		
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NEGATIVE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_NOT_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_BIT_REVERSE_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_PLUS_PLUS_func */
		NULL , /* ZlangUnaryOperatorFunction *unaryoper_MINUS_MINUS_func */
		
		NULL , /* ZlangCompareFunction *comp_EGUAL_func */
		NULL , /* ZlangCompareFunction *comp_NOTEGUAL_func */
		NULL , /* ZlangCompareFunction *comp_LT_func */
		NULL , /* ZlangCompareFunction *comp_LE_func */
		NULL , /* ZlangCompareFunction *comp_GT_func */
		NULL , /* ZlangCompareFunction *comp_GE_func */
		
		NULL , /* ZlangLogicFunction *logic_AND_func */
		NULL , /* ZlangLogicFunction *logic_OR_func */
		
		NULL , /* ZlangLogicFunction *bit_AND_func */
		NULL , /* ZlangLogicFunction *bit_XOR_func */
		NULL , /* ZlangLogicFunction *bit_OR_func */
		NULL , /* ZlangLogicFunction *bit_MOVELEFT_func */
		NULL , /* ZlangLogicFunction *bit_MOVERIGHT_func */
		
		ZlangSummarizeDirectPropertySize_guicombobox , /* ZlangSummarizeDirectPropertySizeFunction *summarize_direct_prop_size_func */
	} ;

ZlangImportObjectFunction ZlangImportObject_guicombobox;
struct ZlangObject *ZlangImportObject_guicombobox( struct ZlangRuntime *rt )
{
	struct ZlangObject	*obj = NULL ;
	struct ZlangFunction	*func = NULL ;
	int			nret = 0 ;
	
	nret = ImportObject( rt , & obj , ZLANG_OBJECT_guicombobox , & direct_funcs_guicombobox , sizeof(struct ZlangDirectFunctions) , NULL ) ;
	if( nret )
	{
		SET_RUNTIME_ERROR( rt , RUNTIME_ERROR , ZLANG_ERROR_LINK_FUNC_TO_ENTITY , "import object to global objects heap" )
		return NULL;
	}
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_Create_guiwindow , ZLANG_OBJECT_guicombobox , "Create" , ZLANG_OBJECT_guiwindow,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_Create_guiwindow_functionptr , ZLANG_OBJECT_guicombobox , "Create" , ZLANG_OBJECT_guiwindow,NULL , ZLANG_OBJECT_functionptr,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_AppendStringItem_string , ZLANG_OBJECT_guicombobox , "AppendStringItem" , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_AppendStringItems_vargs , ZLANG_OBJECT_guicombobox , "AppendStringItems" , ZLANG_OBJECT_vargs,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_InsertStringItem_int_string , ZLANG_OBJECT_guicombobox , "InsertStringItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_SetStringItem_int_string , ZLANG_OBJECT_guicombobox , "SetStringItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_string,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_AppendItem_object_object , ZLANG_OBJECT_guicombobox , "AppendItem" , ZLANG_OBJECT_object,NULL , ZLANG_OBJECT_object,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_InsertItem_int_object_object , ZLANG_OBJECT_guicombobox , "InsertItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_object,NULL , ZLANG_OBJECT_object,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_SetItem_int_object_object , ZLANG_OBJECT_guicombobox , "SetItem" , ZLANG_OBJECT_int,NULL , ZLANG_OBJECT_object,NULL , ZLANG_OBJECT_object,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_SetChangedEventCallback_functionptr , ZLANG_OBJECT_guicombobox , "SetChangedEventCallback" , ZLANG_OBJECT_functionptr,NULL , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_SelectRow_int , ZLANG_OBJECT_guicombobox , "SelectRow" , ZLANG_OBJECT_int,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	ADD_FUNCTION_AND_PARAMETERS_IN_OBJECT_guiwidget_all_common_functions( combobox )

	ADD_FUNCTION_AND_PARAMETERS_IN_OBJECT_guictl_all_common_functions( combobox )

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_Remove_int , ZLANG_OBJECT_bool , "Remove" , ZLANG_OBJECT_int,NULL , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_RemoveAll , ZLANG_OBJECT_void , "RemoveAll" , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_GetItemCount , ZLANG_OBJECT_int , "GetItemCount" , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_GetSelectedRowNo , ZLANG_OBJECT_int , "GetSelectedRowNo" , NULL ) ;
	if( func == NULL )
		return NULL;

	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_GetSelectedRowString , ZLANG_OBJECT_string , "GetSelectedRowString" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	func = AddFunctionAndParametersInObject( rt , obj , ZlangInvokeFunction_guicombobox_GetSelectedRowObject , ZLANG_OBJECT_object , "GetSelectedRowObject" , NULL ) ;
	if( func == NULL )
		return NULL;
	
	return obj ;
}

